/*
 * @des: 浏览器相关信息
 * @author: yyq
 * @Date: 201-01-05
*/


const browser = {
	// 设置全屏
	setFullScreen() {
		let doc = document.documentElement;
		
		if(doc.requestFullscreen) {
			doc.requestFullscreen();
		}else if(doc.webkitRequestFullscreen) {
			doc.webkitRequestFullscreen();
		}else if(doc.mozRequestFullScreen) {
			doc.mozRequestFullScreen();
		}else if(doc.msRequestFullscreen) {
			doc.msRequestFullscreen();
		}
	},
	// 取消全屏
	cancelfullscreen() {
		let doc = document;

		if (doc.exitFullscreen) {
			doc.exitFullscreen();
		}else if (doc.webkitCancelFullScreen) {
			doc.webkitCancelFullScreen();
		}else if (doc.mozCancelFullScreen) {
			doc.mozCancelFullScreen();
		}else if (doc.msExitFullscreen) {
			doc.msExitFullscreen();
		}
	},
	// 判断是否是全屏
	getIsFullScreen() {
		let doc = document,
			isFullScreen =  false;
		
		if (doc.exitFullscreen) {
            isFullScreen = doc.fullscreen;
        } else if (doc.webkitCancelFullScreen) {
            isFullScreen = doc.webkitIsFullScreen;
        } else if (doc.mozCancelFullScreen) {
            isFullScreen = doc.mozFullScreen;
        } else if (doc.msExitFullscreen) {
            isFullScreen = doc.msFullscreenElement;
        }
        return isFullScreen;
	},
	// 全屏改变监听事件
	listenerScrrenChange(callback) {
		let doc = document;

	    if (doc.exitFullscreen) {
	        doc.addEventListener("fullscreenchange", callback);
	    } else if (doc.webkitCancelFullScreen) {
	        doc.addEventListener("webkitfullscreenchange", callback, "wekit");
	    } else if (doc.mozCancelFullScreen) {
	        doc.addEventListener("mozfullscreenchange", callback, "moz");
	    } else if (doc.msExitFullscreen) {
	        doc.addEventListener("MSFullscreenChange", callback, "ie");
	    }
	}
}

export default browser